package com.byxy.action;

import org.eclipse.jdt.internal.compiler.ast.ReturnStatement;

import com.byxy.entity.Employee;
import com.byxy.service.EmployeeService;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 员工
 * @author Administrator
 *
 */
public class EmployeeAction extends ActionSupport implements ModelDriven<Employee> {
  /**
	 * 
	 */
	private static final long serialVersionUID = 542406641569734818L;
	private Employee employee = new Employee();
	@Override
	public Employee getModel() {
		// TODO Auto-generated method stub
		return employee;
	}
	
	//注入業務
	private EmployeeService employeeService;
public EmployeeService getEmployeeService() {
		return employeeService;
	}
	public void setEmployeeService(EmployeeService employeeService) {
		this.employeeService = employeeService;
	}
public String loing() {
	  Employee exisEmployee = employeeService.login(employee);
	  if(exisEmployee == null) {
		 //登录失败
		  this.addActionError("用户名或密码错误");
		  return INPUT;
	  }else {
		  //登陆成功
		  ActionContext.getContext().getSession().put("exisEmployee",exisEmployee);
		  return SUCCESS;
	}
  }
}
